package mvc;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import thread.CustomerThread;
import thread.WorkThread;
import depot.NoExistParcelException;

import gui.WorkerGUI;

/** 
 * @author Ximeng Bao
 * This class handles the interaction with users
 * It calls vie and model as needed
 */

public class ObserverController {

	private WorkerGUI workergui;  //GUI to allow user to set the time

	private ObserverManager oManager;       //clock model stores the time
	
	/**
	 * The constructor of ObserverController class
	 * @param workergui The GUI of the program
	 * @param oManager The ObserverManager
	 */
	public ObserverController(WorkerGUI workergui, ObserverManager oManager) {
		this.oManager = oManager;
		this.workergui = workergui;
		//specify the listener for the view
		workergui.addSetListener(new SetListener());
	}
	
	/**
	 * 
	 * Class to set ActionListener to update button
	 */
	public class SetListener implements ActionListener
	{
		public void actionPerformed (ActionEvent e)
		{
			Logger.logreport("Work speed has successfully changed.");
			int speed = workergui.getSpeed_text();
			oManager.setSpeed(speed);
		}
	}


}
